package server

import (
	"gitlab.local/DO-module/new-filemanage-module/server/auth"
	"gitlab.local/DO-module/new-filemanage-module/server/pubsub"
	"gitlab.local/DO-module/new-filemanage-module/src/service/filesystem"
)

type Option interface {
	Config(*Server)
}

type ipcSockOption struct {
	ipcSockPath string
}

func (o ipcSockOption) Config(s *Server) {
	s.sockPath = o.ipcSockPath
}

type pubSubOption struct {
	pubsub *pubsub.PubSub
}

func (o pubSubOption) Config(s *Server) {
	s.pubsub = o.pubsub
}

type authenticatorOption struct {
	authenticator auth.Authenticator
}

func (o authenticatorOption) Config(s *Server) {
	s.authenticator = o.authenticator
}

func WithIPCSock(ipcSockPath string) Option {
	return ipcSockOption{ipcSockPath: ipcSockPath}
}

func WithPubSub(pubsub *pubsub.PubSub) Option {
	return pubSubOption{pubsub: pubsub}
}

func WithAuthenticator(authenticator auth.Authenticator) Option {
	return authenticatorOption{authenticator: authenticator}
}

type fileSystem struct {
	fs *filesystem.FileSystem
}

func (f fileSystem) Config(s *Server) {
	s.fs = f.fs
}

func WithFileSystem(fs *filesystem.FileSystem) Option {
	return fileSystem{fs: fs}
}
